/**
  * @file    :test.cpp
  * @brief   :测试文件
  * @author  :TMJ
  * @version :V1.0.0
  * @date    :2023-12-30
*/

#include "adjacency_list_graph.hpp"
#include "matrix_graph.hpp"
#include <functional>
#include <iostream>


using namespace std;

/*!
 * @brief **测试-图-基础函数**
 * @note
 * 测试-图-基础函数
 * --------------
 * --------------
 *
 * --------------
 * + **1 初始化图的基本信息**\n\n
 * 初始化结点信息(北京, 上海, 广州, 深圳, 杭州, 成都 6座城市)\n
 * 初始化边信息\n\n
 * + **2 测试基础函数**\n\n
 * 构造adjacency_list_directed_graph(邻接表有向图)\n
 * 依次删除1个城市, 然后打印图\n\n
 * 构造adjacency_list_undirected_graph(邻接表无向图)\n
 * 依次删除1个城市, 然后打印图\n\n
 * 构造matrix_directed_graph(矩阵有向图)\n
 * 依次删除1个城市, 然后打印图\n\n
 * 构造matrix_undirected_graph(矩阵无向图)\n
 * 依次删除1个城市, 然后打印图\n\n
 *
 *
 * --------------
 */
void TestBaseFunctions() {
    cout << endl;
    cout << "|------------------------ CyberDash ------------------------|" << endl;
    cout << "|                  Test Graph BaseFunctions                 |" << endl;
    cout << "|                     测试-图-基础函数                      |" << endl;
    cout << "|                                                           |" << endl;
    cout << "|                           北京                            |" << endl;
    cout << "|                           / \\                             |" << endl;
    cout << "|                          /   \\                            |" << endl;
    cout << "|                        0.1   0.12                         |" << endl;
    cout << "|                        /       \\                          |" << endl;
    cout << "|                       /         \\                         |" << endl;
    cout << "|                    上海---0.01---广州                     |" << endl;
    cout << "|                     / \\         / \\                       |" << endl;
    cout << "|                    /   \\       /   \\                      |" << endl;
    cout << "|                 0.13  0.14   0.05  0.17                   |" << endl;
    cout << "|                  /       \\   /       \\                    |" << endl;
    cout << "|                 /         \\ /         \\                   |" << endl;
    cout << "|             杭州--0.09-- 深圳 --0.11--成都                |" << endl;
    cout << endl;

    // ---------- 1 初始化图的基本信息 ----------

    // 初始化结点信息(北京, 上海, 广州, 深圳, 杭州, 成都 6座城市)
    vector<string> vertices{"北京", "上海", "广州", "深圳", "杭州", "成都"};

    // 初始化边信息
    unsigned int edge_count = 9;

    vector<string> starting_vertices{"北京", "北京", "上海", "上海", "上海", "广州", "广州", "深圳", "深圳"};// 初始化起点数组
    vector<string> ending_vertices{"上海", "广州", "广州", "深圳", "杭州", "深圳", "成都", "杭州", "成都"};  // 初始化终点数组
    vector<double> weights{0.1, 0.12, 0.01, 0.14, 0.13, 0.05, 0.17, 0.09, 0.11};                             // 初始化边权值数组

    vector<Edge<string, double>> edges;// 声明边vector
    // 构造边vector
    for (unsigned int i = 0; i < edge_count; i++) {
        Edge<string, double> edge(starting_vertices[i], ending_vertices[i], weights[i]);
        edges.push_back(edge);
    }

    // ---------- 2 测试基础函数 ----------

    // 构造adjacency_list_directed_graph(邻接表有向图)
    AdjacencyGraph<string, double> adjacency_list_directed_graph(10, edges, vertices, Graph<string, double>::DIRECTED);

    // 依次删除1个城市, 然后打印图
    cout << "---------- 1 邻接表有向图删除结点 ----------" << endl
         << endl;
    adjacency_list_directed_graph.removeVertex("北京");
    adjacency_list_directed_graph.removeVertex("上海");
    adjacency_list_directed_graph.removeVertex("深圳");
    cout << adjacency_list_directed_graph << endl
         << endl;

    // 构造adjacency_list_undirected_graph(邻接表无向图)
    AdjacencyGraph<string, double> adjacency_list_undirected_graph(10, edges, vertices, Graph<string, double>::UNDIRECTED);

    // 依次删除1个城市, 然后打印图
    cout << "---------- 2 邻接表无向图删除结点 ----------" << endl
         << endl;
    adjacency_list_undirected_graph.removeVertex("北京");
    adjacency_list_undirected_graph.removeVertex("上海");
    adjacency_list_undirected_graph.removeVertex("深圳");
    cout << adjacency_list_undirected_graph << endl
         << endl;

    // 构造matrix_directed_graph(矩阵有向图)
    MatrixGraph<string, double> matrix_directed_graph(Graph<string, double>::DIRECTED, 10, 1000, vertices, edges);

    // 依次删除1个城市, 然后打印图
    cout << "---------- 3 矩阵有向图删除结点 ----------" << endl
         << endl;
    matrix_directed_graph.removeVertex("北京");
    matrix_directed_graph.removeVertex("上海");
    matrix_directed_graph.removeVertex("深圳");
    cout << matrix_directed_graph << endl
         << endl;

    // 构造matrix_undirected_graph(矩阵无向图)
    MatrixGraph<string, double> matrix_undirected_graph(Graph<string, double>::UNDIRECTED, 10, 1000, vertices, edges);

    // 依次删除1个城市, 然后打印图
    cout << "---------- 4 矩阵无向图删除结点 ----------" << endl
         << endl;
    matrix_undirected_graph.removeVertex("北京");
    matrix_undirected_graph.removeVertex("上海");
    matrix_undirected_graph.removeVertex("深圳");
    cout << matrix_undirected_graph << endl
         << endl;

    cout << "-------------------------------------------------------------" << endl;
}